package com.runing.utils;


import org.springframework.web.multipart.MultipartFile;

import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class fileUtil {


    public static void upload(MultipartFile file) throws IOException {
        //上传路径
        String uploadPath = "D:\\jar\\run\\file\\app\\";
        /*获取文件名*/
        String getFileName = file.getOriginalFilename();
        String str1=getFileName.substring(0, getFileName.indexOf("."));
        String fileCategory=getFileName.substring(str1.length()+1);
        if (fileCategory.equals("apk")){
            String filePath =uploadPath + getFileName;
            BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(filePath));
            outputStream.write(file.getBytes());
            outputStream.flush();
            outputStream.close();
        }
    }
}

